<?php
/**
 * This file handles the retrieval and serving of news articles
 */
class Latestnews_Controller
{
	/**
	 * This template variable will hold the 'view' portion of our MVC for this 
	 * controller
	 */
	public $template = 'latestnews';
	
	/**
	 * This is the default function that will be called by router.php
	 * 
	 * @param array $getVars the GET variables posted to index.php
	 */
	public function main(array $getVars)
	{
		$latestNewsModel = new Latestnews_Model;
		if(isset($getVars['link_title']) && ($getVars['link_title'])){
			//get an article
			$article = $latestNewsModel->get_article($getVars['link_title']);
		
			//create a new view and pass it our template
			$view = new View_Model($this->template);
		
			//assign article data to view
			$view->assign('article' , $article);
		}
		else{
			header("Location: 404.html");
		}
	}
}